﻿using Rimifier.Properties;
using System.Collections;
using System.Collections.Generic;

namespace Rimifier.Support
{
  public class WeaponList : IEnumerable<WeaponListItem>, IThingList
  {
    public List<WeaponListItem> List { get; private set; }

    public WeaponList()
    {
      List = new List<WeaponListItem>();

      List.AddRange(new[] {        
        new WeaponListItem
        {
          WeaponId = "Gun_Lee-Enfield",
          WeaponName = "Lee-Enfield",
          DisplayName = "Lee-Enfield",
          Class = "Rifle",
          Damage = 18,
          Range = 37F,
          Accuracy = 9,
          FiringMode = "Single",
          BurstSpeed = null,
          Handling = "",
          WarmupCooldown = "182/0",
          Buy = 750,
          Sell = null,
          AimTime = 3.0F,
          DamagePerSecond = 6.0F,
          Tooltip = Resources.Weapon_ToolTips_Lee_Enfield
        },
        new WeaponListItem
        {
          WeaponId = "Gun_M-16Rifle",
          WeaponName = "M-16 Assault Rifle",
          DisplayName = "M-16 Assault Rifle",
          Class = "Rifle",
          Damage = 7,
          Range = 32F,
          Accuracy = 7,
          FiringMode = "Burst (3)",
          BurstSpeed = 7,
          Handling = "+",
          WarmupCooldown = "108/0",
          Buy = 1300,
          Sell = null,
          AimTime = 1.8F,
          DamagePerSecond = 11.0F,
          Tooltip = Resources.Weapon_ToolTips_M16
        },
        new WeaponListItem
        {
          WeaponId = "Gun_R-4 charge rifle",
          WeaponName = "R4 Charge Rifle",
          DisplayName = "R4 Charge Rifle",
          Class = "Rifle",
          Damage = 14,
          Range = 24F,
          Accuracy = 6,
          FiringMode = "Burst (3)",
          BurstSpeed = 12,
          Handling = "+",
          WarmupCooldown = "108/0",
          Buy = 2000,
          Sell = null,
          AimTime = 1.8F,
          DamagePerSecond = 23.3F,
          Tooltip = Resources.Weapon_ToolTips_R4
        },
        new WeaponListItem
        {
          WeaponId = "Gun_M-24Rifle",
          WeaponName = "M-24 Sniper Rifle",
          DisplayName = "M-24 Sniper Rifle",
          Class = "Rifle",
          Damage = 40,
          Range = 45F,
          Accuracy = 8,
          FiringMode = "Single",
          BurstSpeed = null,
          Handling = "",
          WarmupCooldown = "260/100",
          Buy = 1500,
          Sell = null,
          AimTime = 4.3F,
          DamagePerSecond = 9.3F,
          Tooltip = Resources.Weapon_ToolTips_M24
        },
        new WeaponListItem
        {
          WeaponId = "Gun_Pistol",
          WeaponName = "Pistol",
          DisplayName = "Pistol",
          Class = "Single",
          Damage = 10,
          Range = 24F,
          Accuracy = 4,
          FiringMode = "Single",
          BurstSpeed = null,
          Handling = "++",
          WarmupCooldown = "68/0",
          Buy = 250,
          Sell = null,
          AimTime = 1.1F,
          DamagePerSecond = 9.1F,
          Tooltip = Resources.Weapon_ToolTips_Pistol
        },
        new WeaponListItem
        {
          WeaponId = "Gun_Pump Shotgun",
          WeaponName = "Pump shotgun",
          DisplayName = "Pump shotgun",
          Class = "Single",
          Damage = 20,
          Range = 16F,
          Accuracy = 7,
          FiringMode = "Single",
          BurstSpeed = null,
          Handling = "+",
          WarmupCooldown = "108/0",
          Buy = 700,
          Sell = null,
          AimTime = 1.8F,
          DamagePerSecond = 11.1F,
          Tooltip = Resources.Weapon_ToolTips_Pump
        },
        new WeaponListItem
        {
          WeaponId = "Gun_T-9 Incendiary Launcher",
          WeaponName = "T9 Incendiary Launcher",
          DisplayName = "T9 Incendiary Launcher",
          Class = "Single",
          Damage = 4,
          Range = 24F,
          Accuracy = 1,
          FiringMode = "Burst (1)",
          BurstSpeed = 182,
          Handling = "",
          WarmupCooldown = "182/0",
          Buy = 1800,
          Sell = null,
          AimTime = 3.0F,
          DamagePerSecond = 1.3F,
          Tooltip = Resources.Weapon_ToolTips_T9
        },
        new WeaponListItem
        {
          WeaponId = "Gun_Uzi",
          WeaponName = "Uzi",
          DisplayName = "Uzi",
          Class = "SMG",
          Damage = 5,
          Range = 24F,
          Accuracy = 3,
          FiringMode = "Burst (4)",
          BurstSpeed = 7,
          Handling = "+",
          WarmupCooldown = "108/0",
          Buy = 800,
          Sell = null,
          AimTime = 1.1F,
          DamagePerSecond = 18.2F,
          Tooltip = Resources.Weapon_ToolTips_Uzi
        },
        new WeaponListItem
        {
          WeaponId = "Gun_Minigun",
          WeaponName = "Minigun",
          DisplayName = "Minigun",
          Class = "LMG",
          Damage = 5,
          Range = 30F,
          Accuracy = 2,
          FiringMode = "Burst (15)",
          BurstSpeed = 5,
          Handling = "",
          WarmupCooldown = "108/0",
          Buy = null,
          Sell = null,
          AimTime = 1.1F,
          DamagePerSecond = 18.2F,
          Tooltip = Resources.Weapon_ToolTips_MiniGun
        },
        new WeaponListItem
        {
          WeaponId = "Weapon_GrenadeFrag",
          WeaponName = "Frag grenades",
          DisplayName = "Frag grenades",
          Class = "Thrown",
          Damage = 65,
          Range = 12.9F,
          Accuracy = null,
          FiringMode = "Bomb",
          BurstSpeed = null,
          Handling = "",
          WarmupCooldown = "108/120",
          Buy = 1000,
          Sell = null,
          AimTime = null,
          DamagePerSecond = null,
          Tooltip = Resources.Weapon_ToolTips_Frags
        },
        new WeaponListItem
        {
          WeaponId = "Weapon_GrenadeMolotov",
          WeaponName = "Molotov cocktails",
          DisplayName = "Molotov cocktails",
          Class = "Thrown",
          Damage = 15,
          Range = 12.9F,
          Accuracy = null,
          FiringMode = "Flame",
          BurstSpeed = null,
          Handling = "",
          WarmupCooldown = "108/120",
          Buy = 800,
          Sell = null,
          AimTime = null,
          DamagePerSecond = null,
          Tooltip = Resources.Weapon_ToolTips_Molotov
        }
      });

    }

    public void Add(WeaponListItem item)
    {
      List.Add(item);
    }

    public IEnumerator<WeaponListItem> GetEnumerator()
    {
      return List.GetEnumerator();
    }

    IEnumerator IEnumerable.GetEnumerator()
    {
      return GetEnumerator();
    }

    public IThing GetThingById(string id)
    {
      return GetThingByValue(id);
    }

    public IThing GetThingByValue(string value)
    {
      return List.Find(item => item.WeaponId == value);
    }

    public IThing GetThingByIndex(int index)
    {
      return List[index];
    }

  }
}